using System;
using System.Text;
using System.Drawing;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;

using TD.SandDock;

using SBPweb.Themes.Windows;
using SBPweb.Themes.Windows.Skins;
using System.Xml;

namespace SBPweb.Controls.Windows.Docking
{
	/// <summary>
	/// Class of TabbedDocument
	/// </summary>
	public class TabbedDocument : TD.SandDock.TabbedDocument, SBPweb.Themes.Windows.Skins.ISkinnable
	{
		private bool mUseDefaultSkin;
		private Skin mSkin;
		private bool mUseThisBackgrounColorOnChildControls = true;

		/// <summary>
		/// Use this backcolor on child controls or not?
		/// </summary>
		public bool UseThisBackgrounColorOnChildControls
		{
			get { return mUseThisBackgrounColorOnChildControls; }
			set { mUseThisBackgrounColorOnChildControls = value; }
		}
		
		/// <summary>
		/// Constructor of TabbedDocument
		/// </summary>
		public TabbedDocument()
			: base()
		{
		}

		/// <summary>
		/// Constructor of TabbedDocument
		/// </summary>
		/// <param name="manager">sanddock manager</param>
		/// <param name="control">control</param>
		/// <param name="text">text</param>
		public TabbedDocument(SandDockManager manager, Control control, string text)
			: base(manager, control, text)
		{
		}

		/// <summary>
		/// On background paint
		/// </summary>
		/// <param name="e">event args</param>
        protected override void OnPaintBackground(PaintEventArgs e)
        {

            if (Skin != null)
            {
                this.BackColor = Skin.CachedProperties.FormBackColor;
                if (mUseThisBackgrounColorOnChildControls)
                    foreach (Control c in this.Controls)
                    {
                        c.BackColor = Skin.CachedProperties.FormBackColor;
                    }
            }
            base.OnPaintBackground(e);
        }

        #region ISkinnable Members

		/// <summary>
		/// Use default skin?
		/// </summary>
		[Category("Look && feel")]
        public bool UseDefaultSkin
        {
            get
            {
                return mUseDefaultSkin;
            }
            set
            {
                mUseDefaultSkin = value;
                Invalidate();
            }
        }

		/// <summary>
		/// Used skin
		/// </summary>
		[Category("Look && feel")]
        public Skin Skin
        {
            get
            {
                if (this.UseDefaultSkin)
                {
                    return DefaultLookAndFeel.Skin;
                }

                return mSkin;
            }
            set
            {
                mSkin = value;
                Invalidate();
            }
        }

        #endregion

		/// <summary>
		/// Open tabbed document
		/// </summary>
        public override void Open()
        {
            base.Open();
        }

		/// <summary>
		/// "Close" tabbed document
		/// </summary>
        public new void Hide()
        {
            base.Hide();
        }
	}
}
